package me.send.business.base.ocs;

import java.io.IOException;

import net.spy.memcached.AddrUtil;
import net.spy.memcached.ConnectionFactoryBuilder;
import net.spy.memcached.ConnectionFactoryBuilder.Protocol;
import net.spy.memcached.MemcachedClient;
import net.spy.memcached.auth.AuthDescriptor;
import net.spy.memcached.auth.PlainCallbackHandler;

public class OCSHelper {
	private static final String host = "649ca313e7654dd5.m.jst.cnhzalicm10pub001jae001.ocs.aliyuncs.com";// 控制台上的“内网地址”
	private static final String port = "11211"; // 默认端口 11211
	private static final String username = "649ca313e7654dd5";// 账号
	private static final String password = "123_Jae_ASD";// 密码
	private static MemcachedClient cache;
	
	static {
		try {
			AuthDescriptor authDescriptor = new AuthDescriptor(
					new String[] { "PLAIN" }, new PlainCallbackHandler(username,
							password));
			cache = new MemcachedClient(new ConnectionFactoryBuilder()
					.setProtocol(Protocol.BINARY).setAuthDescriptor(authDescriptor)
					.build(), AddrUtil.getAddresses(host + ":" + port));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static MemcachedClient getMemcachedClient(){
		return cache;
	}
}